

* The Government Finance Database available at: https://willamette.edu/mba/research-impact/public-datasets/index.html
* At the time of download, the dataset ran through 2015.

import delimited using ".../The Government Finance Database_All Data.csv"

duplicates drop id total_revenue total_expenditure total_taxes population, force
sort id year4
xtset id year4

drop if type_code == 0 | type_code == 6

save ".../Census.dta", replace

keep if year >= 1995
gen next = 0
replace next = 1 if year == year[_n+1] - 1
replace next = next[_n-1] + 1 if next == 1
replace next = next[_n-1] + 1 if next == 0 & next[_n-1] != 0 & id == id[_n-1] & year == year[_n-1] + 1
by id: egen maxnext = max(next)
keep if maxnext >= 7
keep if year >= 1998

save ".../Census w-restrictions.dta", replace

